<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-30 20:02:30
 * @LastEditTime: 2020-02-28 11:25:38
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style>
        .head {
            display: flex;
        }

        .van-button--primary {
            margin-right: 10px;
            width: 10%;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box">
            <div class="head">
                <van-button size="mini" color="linear-gradient(#fffeaa, #c07d39)" type="primary" @click="refresh">
                    刷 &nbsp &nbsp 新
                </van-button>
                <van-button size="mini" color="linear-gradient(#fffeaa, #c07d39)" type="primary"
                    @click="TiaoJianKaSearch('历史查询')">
                    历史查询
                </van-button>
                <van-button size="mini" color="linear-gradient(#fffeaa, #c07d39)" type="primary"
                    @click="TiaoJianKaSearch('项目查询')">
                    项目查询
                </van-button>
                <van-button size="mini" color="linear-gradient(#fffeaa, #c07d39)" type="primary" @click="copy('复制')">
                    复制
                </van-button>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {

        var browser = api.require('webBrowser');

        api.addEventListener({
            name: 'closeBrowser'
        }, function (ret, err) {
            browser.closeView();
            api.sendEvent({
                name: 'refreshBrowser',
                extra: {
                    breadData: {
                        name: '条件卡',
                        url: 'TiaoJianKa',
                        ZS_FunctionID: 0,
                        click: true
                    }
                }
            })
            api.closeFrame()
        });

        api.addEventListener({
            name: 'refreshBrowser'
        }, function (ret, err) {
            console.log('ret', JSON.stringify(ret))
            if (ret.value.browserData) {
                console.log('code', JSON.stringify(ret.value.browserData.GUCode))
                vm.GUCode = ret.value.browserData.GUCode
                var data = ret.value.browserData
                if (window.localStorage.getItem('clientHeight') != 752) {
                    browser.openView({
                        // url: 'http://developer.yonyou.com',
                        url: data.Location,
                        scaleEnabled: true,
                        rect: {
                            x: 0,
                            y: 150,
                            w: 'auto',
                            h: 'auto'
                        }
                    }, function (ret, err) {
                    });
                } else {
                    browser.openView({
                        // url: 'http://developer.yonyou.com',
                        url: data.Location,
                        scaleEnabled: true,
                        rect: {
                            x: 0,
                            y: 205,
                            w: 'auto',
                            h: 'auto'
                        }
                    }, function (ret, err) {
                    });
                }
            }
        });

        vm = new Vue({
            el: '#app',
            data: {
                GUCode: ''
            },
            created: function () {
                var that = this;
                that.getTiaoJianKa()
            },
            methods: {
                copy() {
                    var that = this
                    console.log('GUCode', that.GUCode)
                    APP.ajax('getFZTJK', { GUCode: that.GUCode }, function (res) {
                        api.toast({
                            msg: res.ds[0].msg
                        })
                        console.log('getFZTJK', JSON.stringify(res))
                    })

                },
                getTiaoJianKa() {
                    var that = this
                    console.log(JSON.stringify(api.pageParam.equipment.EquipmentID))
                    APP.ajax('getTJKHTML', { EquipmentID: api.pageParam.equipment.EquipmentID }, function (res) {
                        console.log('res', JSON.stringify(res))
                        that.GUCode = res.ds1[0].GUCode ? res.ds1[0].GUCode : ''
                        if (window.localStorage.getItem('clientHeight') != 752) {
                            browser.openView({
                                // url: 'http://developer.yonyou.com',
                                url: res.ds[0].html,
                                scaleEnabled: true,
                                rect: {
                                    x: 0,
                                    y: 150,
                                    w: 'auto',
                                    h: 'auto'
                                }
                            }, function (ret, err) {
                            });
                        } else {
                            browser.openView({
                                // url: 'http://developer.yonyou.com',
                                url: res.ds[0].html,
                                scaleEnabled: true,
                                rect: {
                                    x: 0,
                                    y: 205,
                                    w: 'auto',
                                    h: 'auto'
                                }
                            }, function (ret, err) {
                            });
                        }
                    })
                },
                refresh() {
                    var that = this
                    APP.ajax('updateTJKHTML', { GUCode: that.GUCode }, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (!res.ds[0].Column1) {
                            that.getTiaoJianKa()
                        }
                    })
                },
                TiaoJianKaSearch(str) {
                    console.log('pageParam', JSON.stringify(api.pageParam))
                    var that = this
                    api.pageParam.searchType = str
                    api.sendEvent({
                        name: 'resetBreadList',
                        extra: {
                            breadData: {
                                name: str,
                                url: 'TiaoJianKaSearch',
                                ZS_FunctionID: 0,
                                click: true
                            }
                        }
                    })

                    if (window.localStorage.getItem('clientHeight') != 752) {
                        api.openFrame({
                            name: 'TiaoJianKaSearch',
                            url: 'TiaoJianKaSearch.html',
                            rect: {
                                x: 0,
                                y: 115,
                                w: 'auto',
                                h: 'auto',
                            },
                            bgColor: '#29292a',
                            reload: true,
                            pageParam: api.pageParam
                        })
                    } else {
                        api.openFrame({
                            name: 'TiaoJianKaSearch',
                            url: 'TiaoJianKaSearch.html',
                            rect: {
                                x: 0,
                                y: 170,
                                w: 'auto',
                                h: 'auto',
                            },
                            bgColor: '#29292a',
                            reload: true,
                            pageParam: api.pageParam
                        })
                    }
                }
            }
        })
    };
</script>

</html>